<template>
	
 	<div class="layui-layout layui-layout-admin" >
 	  <div class="adminnav1">	
        <Pagetop></Pagetop>
      </div>
      <div class="adminnav2">	
       	<Secondnav urlname="retail"></Secondnav>
      </div>
      
      <!-- 主体内容 -->
      <div class="layui-body kedou-admin" id="LAY_app_body app">
	    <div class="layadmin-tabsbody-item layui-show">
	    	<div class="pagelist">
	    		<div class="layui-card-body">
		      		<fieldset class="layui-elem-field layui-field-title">
					  <legend>余额账单管理</legend>
					</fieldset>
		      	</div>
	    		<div class="pagetop">
	    			<Search :seadate="searchArr"></Search>			    	
		        </div>
		        <div class="layui-card-body">
		        	<div class="buttop" id="buttop">
					    <button type="button" class="layui-btn" @click="getData(0)">全部账单</button>
					    <button type="button" class="layui-btn  layui-btn-primary" @click="getData(1)">奖金结算</button>
					    <button type="button" class="layui-btn  layui-btn-primary" @click="getData(2)">余额抵扣</button>
					    <button type="button" class="layui-btn  layui-btn-primary" @click="getData(3)">提现支出</button>
					    <button type="button" class="layui-btn  layui-btn-primary" @click="getData(4)">手动调整</button>
					    <button type="button" class="layui-btn layui-btn-normal"  @click="daochu">导出</button>
		        	</div>
			        <Tables :fdate="pdate" :result="res" height="430" :totalCount="totalRows" :pageNumber="curindex" :fbtn="btn"></Tables>      			     
		        </div>		      
	        </div>
	    </div>
	  </div>  
	     
	</div>
</template>
<script>	
	import Pagetop from '../common/pagetop.vue'
	import Secondnav from '../common/secondnav.vue'
	import Tables from '../common/tables.vue'
	import Search from '../common/search.vue'
	export default {
	  name: 'balancezd',
	  components: {Pagetop,Secondnav,Tables,Search},	  
	  data () {
	    return {
	        pdate:[], //表头  	
	    	res:"", //内容
	    	totalRows:"",//总数量
	    	curindex:1, //页数
	    	btn:[],//按钮
	    	searchArr:[],//搜索
	    	isShow:false, 
	    	seapram:'',
	    	isclick:'',
	    }
	  },
	  mounted(){ 	
	  	this.getdate();
     	this.getsearch();
	  },
	  methods: {	 	  
		getdate:function(){     	
    	var _this=this;
    	if(_this.isclick==0){
    		var status='';    		
    	}else if(_this.isclick==1){
    		var status='WAITSETTLE';     	
    	}else if(_this.isclick==2){
    		var status='HASBEENSETTLED';
    	}else if(_this.isclick==3){
    		var status='REFUND';
    	}else if(_this.isclick==4){
    		var status='REFUND';	
    	}
    	var url="/huanxinsong/commodity/chainstoregoodslistJson"    	
    	if(_this.seapram){
    		var dates={
	    		pageSize:pageSize,
	    		pageNumber:this.curindex
	    	}
    		var res=_this.seapram;
    		for(var i=0;i<res.length;i++){
    			dates[res[i].key]=res[i].val;
    		}
    		
    	}else{
	    	var dates={
	    		pageSize:pageSize,
	    		pageNumber:this.curindex
	    	}
        }  		    	
        	//alert(url+"//"+JSON.stringify(dates))
      	//ajaxRequest(url,'GET','json',dates,function(ret,err){
      		//alert(url+"//"+JSON.stringify(ret))
	  		var arr=[];  		
		  	arr[0]=[ 
		       {field: 'a', title: 'ID',}
		      ,{field: 'b', title: '分享商',}
		      ,{field: 'c', title: '变更项',}
		      ,{field: 'd', title: '变更金额（元）',}
		      ,{field: 'e', title: '当前金额（元）',}
		      ,{field: 'f', title: '详情说明',}
		      ,{field: 'g', title: '时间',}		     	      
		    ];
		    var res1=[]
		    res1=[{a:'1',b:'小m',c:'余额抵扣',d:'-100',e:'0',f:'订单号：1234567890',g:'2020-5-1'},{a:'2',b:'小m',c:'奖金结算',d:'+100',e:'100',f:'订单号：1234567890',g:'2020-5-1'},]	    		  	
		  	
		  	_this.pdate=arr;		  	
		  	_this.res=res1; //ret.content.result;		  
		  	_this.totalRows=ret.content.totalCount;
		  	_this.curindex=ret.content.pageNumber;		  	
	   // })	
    },     
     getsearch:function(){
    	var arr=[
    		{field: 'b', title: '分享商',type: 'input'}     	
    	];
    	this.searchArr=arr;
   	
    },
    page:function(index,obj){
    	//alert(JSON,stringify(obj))
    	this.curindex=index;
    	this.getdate();
    	
    }, 
    sousuo:function(pram){
    	//alert(JSON.stringify(pram))
    	this.seapram=pram;
    	this.res='';
    	this.totalRows='';
    	this.curindex=1;
    	this.getdate();
    },
     getData:function(is){
    	this.isclick=is;
    	this.getdate();
    	if(is==0){
    	  $('#buttop').find('.layui-btn:eq(0)').removeClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(1)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(2)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(3)').addClass('layui-btn-primary')
    	}else if(is==1){
    	  $('#buttop').find('.layui-btn:eq(1)').removeClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(0)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(2)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(3)').addClass('layui-btn-primary')  
    	}else if(is==2){
    	  $('#buttop').find('.layui-btn:eq(2)').removeClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(0)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(1)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(3)').addClass('layui-btn-primary')
    	}else if(is==3){
    	  $('#buttop').find('.layui-btn:eq(3)').removeClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(0)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(1)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(2)').addClass('layui-btn-primary')
    	}else if(is==4){
    	  $('#buttop').find('.layui-btn:eq(4)').removeClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(0)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(1)').addClass('layui-btn-primary')
    	  $('#buttop').find('.layui-btn:eq(2)').addClass('layui-btn-primary') 
    	  $('#buttop').find('.layui-btn:eq(3)').addClass('layui-btn-primary')  
    	}
        
	},
    daochu:function(){
    	 alert('开发中')
    },
    addData:function(){     
       // this.$router.push({name:'jfadd'})	
	},
	editInfo:function(data){
		//this.$router.push({name:'jfadd',query:{'shopId':data.shopId,'commodityId':data.commodityId}})	
	},

	screens:function(){
		return screen();
	},	
  },
  updated:function(){
  	this.isShow = true;
	layui.use('form', function(){
	  var form = layui.form;
	  form.render();	 
	});
  },
}
</script>
<style scoped>
/**/
</style>
